<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Document</title>
  <style>
    /* body,
      html {
        width: 100%;
        height: 100%;
        margin: 0;
      } */
    div {
      box-sizing: border-box;
      width: 300px;
      height: 300px;
      margin: 150px;
      cursor: default;
      /*n 上，e右，s下，w左*/
      border: 1px solid #000;
    }

    ul {
      background: salmon;
    }
  </style>
</head>

<body>
  <div>
    <ul></ul>
  </div>
  <script>
    let mlo_kuo = ['}', ']', ')']
    let kuo = ['{', '[', '(']
    let o = {
      '}': '{',
      ']': '[',
      ')': '(',
    }
    function test(str) {
      let stack = []
      let i = 0
      while (str && str[i]) {
        if (!o[str[i]]) {
          stack.push(str[i])
        } else if (o[str[i]]) {
          if (stack.pop() !== o[str[i]]) {
            return false
          }
        }
        i++
      }
      return stack.length === 0
    }
    console.log(test('([{}])'));
  </script>
</body>

</html>